package hlhj.fhp.checkpoint.module

import android.content.Context
import com.example.mymvp.mvp.BaseModule
import com.lzy.okgo.model.Response
import hlhj.fhp.checkpoint.http.Apis
import hlhj.fhp.checkpoint.http.CustomAction
import hlhj.fhp.checkpoint.http.LoadingAction
import hlhj.fhp.checkpoint.javaBean.ViolationOrderBean
import hlhj.fhp.checkpoint.javaBean.YearOrderBean

/**
 * Created by Never Fear   on 2018\11\12 0012.
Never More....
 */
class OrderListModule :BaseModule {
    var listener:OrderListListener?=null

    fun getYearOrder(status: Int,page: Int,c: Context){
        Apis?.getYearOrderLists(status, page)
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :CustomAction<Response<YearOrderBean>>(c){
                                override fun httpSuccess(t: Response<YearOrderBean>) {
                                    listener?.yearOrderResp(t.body())
                                }
                            })
                }
    }
    fun getViolationOrder(status:Int, page:Int, c:Context){
        Apis?.getViolationOrder(status, page)
                ?.let {
                    it.doOnSubscribe(LoadingAction(c))
                            .subscribe(object :CustomAction<Response<ViolationOrderBean>>(c){
                                override fun httpSuccess(t: Response<ViolationOrderBean>) {
                                    listener?.violationOrderResp(t.body())
                                }
                            })
                }
    }
    interface OrderListListener{
        fun violationOrderResp(violationOrderBean: ViolationOrderBean)
        fun yearOrderResp(yearOrderBean: YearOrderBean)
    }
}